package com.fable.sp.core.domain;

import com.fable.sp.core.util.JSONType;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Map;

/**
 * .
 *
 * @author stormning on 16/8/12.
 */
@Entity
@Table(name = "sp_container_table")
public class ContainerTable implements Serializable {

    @Id
    @Column(name = "container_id")
    private Long containerId;

    @Column(name = "table_name")
    private String tableName;

    @Type(type = JSONType.TYPE)
    @Column(name = "instance_columns", length = 100000)
    /** {instanceId:columnDef} */
    private Map<Long, ColumnDef> instanceColumns;

    public Long getContainerId() {
        return containerId;
    }

    public void setContainerId(Long containerId) {
        this.containerId = containerId;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Map<Long, ColumnDef> getInstanceColumns() {
        return instanceColumns;
    }

    public void setInstanceColumns(Map<Long, ColumnDef> instanceColumns) {
        this.instanceColumns = instanceColumns;
    }

    public String genClassName() {
        return "Auto" + containerId;
    }
}
